<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="824.41">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #000000; min-height: 14.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #000000}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #bf0000}
span.s1 {font: 18.0px Helvetica}
span.s2 {color: #15439f}
span.s3 {font: 12.0px Helvetica}
span.s4 {font: 14.0px Helvetica}
span.s5 {color: #0000bf}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>Friction<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></b></span><b>A physical model of a system with dry-friction. A chaotic filter.</b></p>
<p class="p2"><br></p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="s2">Friction</span>.ar(in, friction = 0.5, spring = 0.414, damp = 0.313, mass = 0.1, beltmass = 1)</p>
<p class="p2"><br></p>
<p class="p3">The input is treated as the driving force in a physical model of a mass resting on a belt, which can stick or slip relative to the belt (depending on the friction between the two). The input represents the position of the belt, and the mass is held approximately in place by a spring and a damper.</p>
<p class="p2"><br></p>
<p class="p3">The output is the position of the mass, which in very high-friction situations will be exactly the same as the input - but when the other forces can overcome the friction then stick-and-slip alternatiions will typically occur.</p>
<p class="p2"><br></p>
<p class="p4"><span class="s3"><img src="attachments/Friction/friction1-diaram.png" alt="attachments/Friction/friction1-diaram.png"></span></p>
<p class="p3">The model (and the diagram) is inspired by the one considered in this research artcle:</p>
<p class="p2"><br></p>
<p class="p3"><span class="Apple-tab-span">	</span>A. Luo and B. Gegg,<span class="s4"> </span><i>Dynamics of a harmonically excited oscillator with dry-friction on a sinusoidally time-varying, traveling surface</i>, <b>International Journal of Bifurcation and Chaos</b>, 16 (2006), pp. 3539–3566.</p>
<p class="p2"><br></p>
<p class="p3">To create the system studied in that paper (which analyses chaotic stick-and-slip oscillations), the input should be a sinusoid added to an ever-increasing ramp value. But for musical effects you can do different things.</p>
<p class="p2"><br></p>
<p class="p3">Note that DC offset <i>will</i> have a qualitative effect on the system's behaviour (because of the spring being stretched), so feel free to experiment with adding/removing DC.</p>
<p class="p2"><br></p>
<p class="p2"><br></p>
<p class="p3"><b>Examples</b></p>
<p class="p5"><br></p>
<p class="p6">s = <span class="s5">Server</span>.internal;</p>
<p class="p6">s.boot;</p>
<p class="p5"><br></p>
<p class="p6">(</p>
<p class="p7">// This filters a simple sine wave, producing a chaotic result</p>
<p class="p6">x = {</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s5">var</span> sig, out;</p>
<p class="p6"><span class="Apple-tab-span">	</span>sig = <span class="s5">SinOsc</span>.ar(660);</p>
<p class="p6"><span class="Apple-tab-span">	</span>out = <span class="s5">Friction</span>.ar(sig, friction: 5.41322e-5, mass: 8.05501);</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s5">Pan2</span>.ar(out, 0, 0.1);</p>
<p class="p6">}.scope</p>
<p class="p6">)</p>
<p class="p5"><br></p>
<p class="p6">x.free;</p>
<p class="p5"><br></p>
<p class="p6">(</p>
<p class="p7">// Modulate the parameters by moving the mouse. Left speaker is original (modulated) sine wave, right speaker is filtered.</p>
<p class="p6">x = {</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s5">var</span> sig, out;</p>
<p class="p6"><span class="Apple-tab-span">	</span>sig = <span class="s5">SinOsc</span>.ar((<span class="s5">LFPulse</span>.kr(0.5) + <span class="s5">LFPulse</span>.kr(0.33)).range(220, 660).lag(0.1));</p>
<p class="p6"><span class="Apple-tab-span">	</span>out = <span class="s5">Friction</span>.ar(sig, friction: <span class="s5">MouseX</span>.kr(0.00001, 0.03, 1), mass: <span class="s5">MouseY</span>.kr(0.2, 10, 1));</p>
<p class="p5"><span class="Apple-tab-span">	</span></p>
<p class="p6"><span class="Apple-tab-span">	</span>[sig, out] * 0.1;</p>
<p class="p6">}.scope</p>
<p class="p6">)</p>
<p class="p5"><br></p>
<p class="p6">x.free;</p>
<p class="p5"><br></p>
<p class="p6">(</p>
<p class="p7">// Some Ringz oscillators, each with a _separate_ Friction1, then merged to create a "rusty" klank.</p>
<p class="p7">// Note the way the effect changes as the sound dies away.</p>
<p class="p6">x = {</p>
<p class="p6"><span class="s5">var</span> imp, klank, rusty;</p>
<p class="p6">imp = <span class="s5">Impulse</span>.ar(1, 0, 0.1);</p>
<p class="p6">klank = <span class="s5">Ringz</span>.ar(imp, [800, 1071, 1153, 1723]);</p>
<p class="p5"><br></p>
<p class="p6">rusty = <span class="s5">Friction</span>.ar(klank,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span>friction: 1.75584e-5,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span>mass: 2.69789);</p>
<p class="p5"><br></p>
<p class="p6"><span class="s5">Pan2</span>.ar(rusty.sum)</p>
<p class="p6">}.play(s);</p>
<p class="p6">)</p>
<p class="p5"><br></p>
<p class="p6">x.free;</p>
<p class="p5"><br></p>
<p class="p6">(</p>
<p class="p7">// In this one we can play with the DC offset and the spring stiffness</p>
<p class="p6">x = {</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s5">var</span> sig, out;</p>
<p class="p6"><span class="Apple-tab-span">	</span>sig = <span class="s5">SinOsc</span>.ar(330) + <span class="s5">MouseX</span>.kr(0.01, 10, 1);</p>
<p class="p5"><br></p>
<p class="p6"><span class="Apple-tab-span">	</span>out = <span class="s5">Friction</span>.ar(sig, friction: 5.41322e-5, mass: 8.05501,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>spring: <span class="s5">MouseY</span>.kr(0,1));</p>
<p class="p5"><span class="Apple-tab-span">	</span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s5">Pan2</span>.ar(out * 0.1);</p>
<p class="p6">}.scope</p>
<p class="p6">)</p>
<p class="p5"><br></p>
<p class="p6">x.free;</p>
<p class="p5"><br></p>
<p class="p6">(</p>
<p class="p7">// Similar, but this time as a filter for a control-rate signal.<span class="Apple-converted-space"> </span></p>
<p class="p7">// Converts boring sinusoidal freq undulation into something much more interesting...</p>
<p class="p6">x = {</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s5">var</span> sig, out;</p>
<p class="p6"><span class="Apple-tab-span">	</span>sig = <span class="s5">LFPar</span>.kr(33) + <span class="s5">MouseX</span>.kr(0.01, 10, 1);</p>
<p class="p5"><br></p>
<p class="p6"><span class="Apple-tab-span">	</span>out = <span class="s5">Friction</span>.kr(sig, friction: 5.41322e-5, mass: 8.05501,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>spring: <span class="s5">MouseY</span>.kr(0,1));</p>
<p class="p5"><span class="Apple-tab-span">	</span></p>
<p class="p6"><span class="Apple-tab-span">	</span>out = <span class="s5">SinOsc</span>.ar(out.range(150,500));</p>
<p class="p5"><span class="Apple-tab-span">	</span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s5">Pan2</span>.ar(out * 0.1);</p>
<p class="p6">}.scope</p>
<p class="p6">)</p>
<p class="p5"><br></p>
<p class="p6">x.free;</p>
</body>
</html>
